package com.demo.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.time.LocalDateTime;

@Controller
public class TestController {

    @RequestMapping("/test")
    public String helloWord(){
        System.out.println("访问 login 后台... nowtime = "+ LocalDateTime.now().toLocalTime());
        return "test";
    }

    @RequestMapping("/testsession")
    public String login(HttpServletRequest request, HttpServletResponse response, Model model){
        HttpSession session = request.getSession();
//        session.setAttribute("currentSessionId",session.getId());
        System.out.println("测试 redis session ,sid= "+ session.getId());
        model.addAttribute("sessionid",session.getId());
        return "testsession";
    }
}